<template>
  <div @click.self="fn" class="swiper" >
    <van-swipe :initial-swipe="index - 1" :show-indicators="false" @change="changIndex" class="swiper_context" ref="swiper">
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img width="100%" height="300px" v-lazy="image.Url.split('{0}')[0] + '3.JPG'" />
      </van-swipe-item>
    </van-swipe>

    <!-- 数量 -->
    <div class="count_box">
        {{ index }} / {{ allCount }}
    </div>
  </div>
</template>

<script>
export default {
  props: ["mySwiperList", "mySwiperCount"],
  data() {
    return {
      images: [],
      allCount: null,
      index: null
    };
  },
  watch: {
      mySwiperList: {
          deep: true,
          handler(newVal) {
              this.images = newVal.List
              this.allCount = newVal.Count
              console.log(this.images)
          }
      },
      mySwiperCount(index) {
          this.index = index
      }
  },
  mounted() {
    setTimeout(() => {
      this.$refs.swiper.resize();
    }, 500)
  },
  methods: {
      fn() {
          this.$emit("setSwiperFlag", false)
      },
      changIndex(index) {
          this.index = index + 1
      }
  }
};
</script>

<style lang="scss" scoped>

.swiper {
  position: fixed;
  top: 0;
  width: 100%;
  height: 100%;
  background: black;
  z-index: 99999;
}
.swiper_context {
    margin-top: 180px;
    z-index: 9999999;
}

.count_box {
    position: absolute;
    left: 0;
    bottom: 20px;
    color: #fff;
    font-size: 12px;
}
</style>